/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package BookTransaction;

import Admission.AdmissionBean;
import Book.BookBean;
import Book.BookDetailsBean;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Mukesh
 */
public class StudentLibraryStatus extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            String Email = request.getParameter("uid");
            Vector<Object> list = BookTransaction.Query.viewMovementLogAStu(Email);
            if (!list.isEmpty()) {
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    AdmissionBean ab = (AdmissionBean) it.next();
                    BookTransBean btb =ab.getBookTranBean();
                    BookDetailsBean bdb = btb.getBookDetailsBean();
                    BookBean bb = btb.getBookBean();
                    out.println("<tr id='" + btb.getBookTransactionId() + "'>");
                    out.println("<center><td>" + btb.getBookNo() + "</td></center>");
                    out.println("<td>" + bb.getBookName() + "</td>");
                    out.println("<td>" + bb.getPublisher() + "</td>");
                    out.println("<td>" + btb.getIssueDate() + "</td>");
                    out.println("<td>" + btb.getRetruningDate() + "</td>");
                    out.println("<td>" + btb.getFine() + "</td>");
                    if (btb.getBookStatus() == 1) {
                        out.println("<td>Issued</td>");
                    } else if (btb.getBookStatus() == 0) {
                        out.println("<td>Return</td>");
                    }
                    //out.println("<td>" + rtb.getEntryDate() + "</td>");
                    out.println("</tr>");
                }
            } else {
                out.println("<tr>");
                out.println("<td colspan='3'>");
                out.println("<b>No Record Found</b>");
                out.println("</td>");
                out.println("</tr>");
            }
        } catch (Exception e) {
            out.println(e);
        } finally {
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
